package com.bjpowernode.boss.events.listener;

import com.bjpowernode.boss.client.email.EmailClient;
import com.bjpowernode.boss.client.email.EmailEntity;
import com.bjpowernode.boss.events.model.SendEmailEvent;
import jakarta.annotation.Resource;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
public class SendEmailListener implements ApplicationListener<SendEmailEvent> {

    @Resource
    private EmailClient emailClient;

    @Override
    @Async
    public void onApplicationEvent(SendEmailEvent event) {

        EmailEntity emailEntity = event.getEmailEntity();
        Boolean b = emailClient.sendEmail(emailEntity);

    }
}
